package com.dhj.methodsTest;

public class Demo4 {

    public static void main(String[] args) {

        String str = subAuthorName("DaHuaJia", new UseString() {
            @Override
            public String use(String str, int start, int length) {
                return str.substring(start, length);
            }
        });
        System.out.println(str);

        System.out.println("------------------------");



        String str2 = subAuthorName("DaHuaJia", (str1, start, length) -> str1.substring(start, length));
        System.out.println(str2);



        System.out.println("------------------------");

        String str3 = subAuthorName("DaHuaJia", String::substring);
        System.out.println(str3);



    }


    public static String subAuthorName(String str, UseString useString) {
        int start = 0;
        int length = 1;
        return useString.use(str, start, length);
    }


    interface UseString {
        String use(String str, int start, int length);
    }

}
